﻿Imports Kairyu.DCEngine

''' <summary>
''' 結合テーブルマップ
''' </summary>
''' <remarks></remarks>
Public Class RelatedTableMap
    Inherits TableMap

    ''' <summary>
    ''' 結合タイプ
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Property RelationType As RelationTypes

    Private _relatedProperties As New List(Of RelatedProperty)
    ''' <summary>
    ''' 結合プロパティ
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public ReadOnly Property RelatedProperties As IList(Of RelatedProperty)
        Get
            Return _relatedProperties
        End Get
    End Property

    ''' <summary>
    ''' インスタンスを取得します
    ''' </summary>
    ''' <param name="baseInstance"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function GetInstance(baseInstance As Object) As Object
        Dim obj = Me.RelatedProperties.First.GetValue(baseInstance, Nothing)
        Return obj
    End Function

    Private _isNullable As Boolean = False
    ''' <summary>
    ''' 外部結合かどうかを示します
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks>Nullableの伝搬があるため、ここで外部結合判定します。</remarks>
    Public Property IsNullable As Boolean
        Get
            Return _isNullable
        End Get
        Friend Set(value As Boolean)
            _isNullable = value
        End Set
    End Property

End Class